package com.dotflat.fin.dto;

import com.dotflat.fin.domain.ProductSolution;
import com.dotflat.rest.PO.AreableObjectBasePO;
import com.dotflat.rest.domain.AreableObjectBase;
import com.matt.commons.exception.BusinessException;
import com.matt.domain.Product;
import com.matt.foundation.model.ErrorCode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Set;

/**
 *  收费计划
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class ProductSolutionListDTO extends AreableObjectBasePO {
    // 收费方案名称 金额 启用状态 备注
    @ApiModelProperty("VARCHAR(32) COMMENT '计划名称'")
    private String name;

    @ApiModelProperty("VARCHAR(128) COMMENT '账单标题'")
    private String remark;

    @ApiModelProperty("是否启用")
    private Boolean enabled;

    @ApiModelProperty("总价格")
    private BigDecimal fullAmount;

    public static ProductSolutionListDTO of(ProductSolution solution){
        if (solution == null){
            throw new BusinessException(ErrorCode.PARAM_CAN_NOT_BLANK, "产品方案为空");
        }
        ProductSolutionListDTO ret = new ProductSolutionListDTO();

        ret.setId(solution.getId());
        ret.setRemark(solution.getRemark());
        ret.setName(solution.getName());
        ret.setEnabled(solution.getEnabled());
        ret.setFullAmount(solution.getFullAmount());

        return ret;
    }

}
